/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BLO;

import DAO.CustomersDAO;
import DTO.Customers.Customer;
import DTO.Customers.Customers;
import util.SupportUtil;

/**
 *
 * @author ThanhTai
 */
public class CustomersBLO {

    public String checkCustomerLogin(String username, String password) {
        try {
            CustomersDAO dao = new CustomersDAO();
            Customers customers = dao.checkCustomerLogin(username, password);
            SupportUtil util = new SupportUtil();
            if (customers == null || customers.getCustomer() == null || customers.getCustomer().size() < 1) {
                return null;
            }
            return util.marshalReturnString(customers);
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }

    public boolean isEmailExisted(String email) {
        try {
            CustomersDAO dao = new CustomersDAO();
            return dao.isEmailExisted(email);
        } catch (Exception ex) {
            ex.printStackTrace();
            return true;
        }
    }

    public boolean InsertCustomer(Customer customer) {
        try {
            CustomersDAO dao = new CustomersDAO();
            return dao.InsertCustomer(customer);
        } catch (Exception ex) {
            ex.printStackTrace();
            return false;
        }
    }
}
